<template>
	<view>
		<button @click="onstetimecall()">单次定时器settimeout</button>
		<button @click="onstetimecallxy(name,pwd)">单次定时器settimeout</button>
		<button @click="onstetimeoutclear(name,pwd)" type="warn">取消定时器</button>
		<button @click="oninterval(name,pwd)" type="primary">周期打印</button>
		<button @click="onclearinter(name,pwd)" type="primary">周期打印</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			onsettimecall(){
				console.log("onsettimeout-->");
				//
				//setTimeout(callback,ms,ayn[]);
			setTimeout(()=>{
				console.log("两秒打印");
			},2000)
			}
			onstetimecallxy(name,pwd){
				console.log("onstetimecallxy-->"+name+",pwd"+pwd);
				//console.log("onstetimecallxy-->"+this.username+",pwd"+this.paword);
				this.timeoutid=setTimeout((x,y)=>{
					console.log("传参"+x+""+pwd);
				},2000 , name , pwd)
				},
				onstetimeoutclear(){
					console.log("ontimeoutclear--->"+this.timeoutid);
					clearTimeout(this.timeoutid);
				}
				oninterval(){
					setInterval(()=>{
						this.count++;
						console.log("周期打印",this.count);
					},1000)
				}
			onclear(){
				console.log("",this.intid);
				clearInterval(this.intid)
			}
			}
	}
	}
</script>

<style>

</style>
